home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / lib / hilbert.pro < prev    next >
Text File  |  1997-07-08  |  2KB  |  72 lines

  1. ; $Id: hilbert.pro,v 1.3 1997/01/15 03:11:50 ali Exp $
  2. ;
  3. ;+
  4. ; NAME:
  5. ;    HILBERT
  6. ;
  7. ; PURPOSE:
  8. ;    Return a series that has all periodic terms shifted by 90 degrees. 
  9. ;
  10. ; CATEGORY:
  11. ;    G2 - Correlation and regression analysis
  12. ;    A1 - Real arithmetic, number theory.
  13. ;
  14. ; CALLING SEQUENCE:
  15. ;    Result = HILBERT(X [, D])
  16. ;
  17. ; INPUT:
  18. ;    X:    A floating- or complex-valued vector containing any number 
  19. ;        of elements.
  20. ;
  21. ; OPTIONAL INPUT:
  22. ;    D:    A flag for rotation direction.  Set D to +1 for a 
  23. ;        positive rotation.  Set D to -1 for a negative rotation.
  24. ;        If D is not provided, a positive rotation results.
  25. ;
  26. ; OUTPUTS:
  27. ;    Returns the Hilbert transform of the data vector, X.  The output is 
  28. ;    a complex-valued vector with the same size as the input vector.
  29. ;
  30. ; COMMON BLOCKS:
  31. ;    None.
  32. ;
  33. ; SIDE EFFECTS:
  34. ;    HILBERT uses FFT() so this procedure exhibits the same side 
  35. ;    effects with respect to input arguments as that function.
  36. ;
  37. ; PROCEDURE:
  38. ;    A Hilbert transform is a series    that has had all periodic components 
  39. ;    phase-shifted by 90 degrees.  It has the interesting property that the 
  40. ;    correlation between a series and its own Hilbert transform is 
  41. ;    mathematically zero.
  42. ;
  43. ;    The method consists of generating the fast Fourier transform using 
  44. ;    the FFT() function and shifting the first half of the transform 
  45. ;    products by +90 degrees and the second half by -90 degrees.  The 
  46. ;    constant elements in the transform are not changed.
  47. ;
  48. ;    Angle shifting is accomplished by multiplying or dividing by the 
  49. ;    complex number, I=(0.0000, 1.0000).  The shifted vector is then
  50. ;    submitted to FFT() for transformation back to the "time" domain and the
  51. ;    output is divided by the number elements in the vector to correct for
  52. ;    multiplication effect peculiar to the FFT algorithm.  
  53. ;
  54. ; REVISION HISTORY:
  55. ;    JUNE, 1985,    Written, Leonard Kramer, IPST (U. of Maryland) on site
  56. ;            contractor to NASA(Goddard Sp. Flgt. Cntr.)
  57. ;-
  58.     FUNCTION HILBERT,X,D   ; performs the Hilbert transform of some data.
  59.     ON_ERROR,2           ; Return to caller if an error occurs
  60.     Y=FFT(X,-1)         ; go to freq. domain.
  61.     N=N_ELEMENTS(Y)
  62.     I=COMPLEX(0.0,1.0)
  63.     IF N_PARAMS(X) EQ 2 THEN I=I*D
  64.     N2=N/2-1         ; effect of odd and even # of elements 
  65.                  ; considered here.
  66.     Y[1]=Y[1:N2]*I       ; multiplying by I rotates counter c.w. 90 deg.
  67.     N2=N-N2
  68.     Y[N2]=Y[N2:N-1]/I
  69.     Y=FFT(Y,1)  ; go back to time domain
  70.     RETURN,Y
  71. END
  72.